package jwm.data;

import gui.MainWindow;
import jwm.Main;

public class Proccessor extends Thread {

   private URLQueue queue;
   private MainWindow window;
   
   public Proccessor() {
      window = new MainWindow();
      queue = new URLQueue();
      RatedURL rurl = new RatedURL(Main.url);
      new PageSearcher(rurl, queue, this);
   }

   @Override
   public void run() {
      while (true) {
         if (queue.left() > 0) {
            new PageSearcher(queue.poll(), queue, this);
            window.refresh(queue.passed(), queue.left() + queue.passed());
         } else {
            synchronized (this) {
               try {
                  wait();
               } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
               }
            }
         }
      }
   }

}
